package com.learn.training.multithread.chapter6.minchapter4.demo1;

public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Counter c1 = new Counter();

        for (int i = 0; i < 5; i++) {
            Thread t = new Thread(){
                public void run() {
                    for (int i = 0; i < 10000; i++) {
                        c1.add(1);
                    }
                }
            };
        }

        for (int i = 0; i < 5; i++) {
            Thread t = new Thread(){
                public void run() {
                    for (int i = 0; i < 10000; i++) {
                        c1.dec(1);
                    }
                }
            };
        }

        System.out.println(c1.get());

    }
}
